package com.game.config;

import com.game.utils.GamePreference;
import com.game.utils.GameSoundManager;

import android.util.Log;


/**
 * 默认类,保存默认信息*/
public class Config {
	//屏幕相关-------------------------------------------------------------------
	public static final int SCREEN_WIDTH=854;//默认的屏幕宽
	public static final int SCREEN_HEIGHT=480;//默认的屏幕高
	
	//绘图相关------------------------------------------------------------------
	public static final float DEF_FPS=60f;
	public static final float FPS=30f;
	public static final float MAX_FPS=1000f/FPS;
	public static final float FPS_RATE = MAX_FPS/1000f;
	public static final long SCREEN_FLUSH_TIME=(long)MAX_FPS;//默认的刷新频率
	public static boolean FULL_SCREEN=true;//全屏/非全屏的开关,非全屏拉伸不会走样
	
	public static boolean DRAW_FPS=true;//调试 显示屏幕刷新频率
	public static boolean DRAW_REGION=true;//显示精灵的区域
	
	//数据相关-----------------------------------------------------------------需进行配置
	public static final String[] GAME_PREFERENCE=new String[]{"sound"};//首选项s
	public static final Object[] GLOBAL_SETTINGS=new Object[]{0};//默认设置值
	public static final int SETTING_INDEX_SOUND=0;
	public static final int DATABASE_VERSON=1;//标识数据库版本
	public static final String DB_NAME="myGameDb";//游戏数据库名
	public static final String[] TABLES=new String[]{};//表名S
	
	/*获取声音设置*/
	public static int getSoundSetting(){
		return (Integer)GLOBAL_SETTINGS[SETTING_INDEX_SOUND];
	}
	
	/*判断声音是否开启*/
	public static boolean isSoundOn(){
		return (Integer)GLOBAL_SETTINGS[SETTING_INDEX_SOUND]>=1;
	}
	
	/*开关声音*/
	public static void switchSoundSetting(){
		if((Integer)GLOBAL_SETTINGS[SETTING_INDEX_SOUND]==0){
			GLOBAL_SETTINGS[SETTING_INDEX_SOUND]=1;
			GameSoundManager.instance.palyMusic();
		}
		else{
			GLOBAL_SETTINGS[SETTING_INDEX_SOUND]=0;
			GameSoundManager.instance.pauseMusic();
		}
		GamePreference.instance.saveConfigInteger(SETTING_INDEX_SOUND, (Integer)GLOBAL_SETTINGS[SETTING_INDEX_SOUND]);
	}
	
	/*加载所有游戏设置,需重写此方法*/
	public static void ReadAllConfigs(){
		GLOBAL_SETTINGS[0]=GamePreference.instance.getConfigInteger(0);
		Log.i("infos", Config.getSoundSetting()==1?"声音开启":"声音关闭");
	}
	
}